<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_content.css">
    <!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css" />
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="js/app.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
</head>
<body>
    <div class="nav">
        <img src="img/Personal_blog.png" alt="">
        <span class="title">个人博客</span>
        <span class="spacer"></span>
        <a href="delete" id="delete">删除</a>
        <a href="blog_list.html">主页</a>
        <a href="blog-edit.html">写博客</a>
        <a href="loginOut">注销</a>
    </div>
    <div class="container">
        <div class="container-left">
            <div class="card">
                <img src="img/head_sculpture.jpg" class="avtar" alt="">
                <h3>负责人:</h3>
                <h2 class="userName"></h2>
                <div class="contact1">联系方式</div>
                <div class="contact2"></div>
                <div class="counter">
                    <span>文章： </span>
                    <span class="blogCount"></span>
                </div>
            </div>
        </div>
        <div class="container-right">
            <div class="blog-content">
                <h3></h3>
                <div class="date"></div>
<!--                应用父元素的样式-->
                <p id="content" style="background: transparent">
                </p>
            </div>
        </div>
    </div>
<script>
    function getContent(){
        $.ajax({
           type:"get",
            //location获取url上的查询字符串,此处为blogId
           url:"blog"+location.search,
            success:function (body) {
                let h=document.querySelector(".blog-content>h3");
                h.innerHTML=body.title;
                let date=document.querySelector(".blog-content>div");
                date.innerHTML=body.postTime;
                editormd.markdownToHTML('content',{markdown:body.content});
            }

        });
    }
    function getUserInfo(){
        $.ajax({
            type: "get",
            url: "userInfo"+location.search,
            success:function (body){
                let userName=document.querySelector(".container-left>.card>.userName")
                userName.innerHTML=body.userName;
                let contact=document.querySelector(".container-left>.card>.contact2");
                contact.innerHTML=body.contact;
                let blogCount=document.querySelector(".container-left>.card>.counter>.blogCount");
                blogCount.innerHTML=body.blogCount;
            }
        });
    }
    //先行拼接href
    function upDataDelete(){
        let del=document.querySelector("#delete");
        del.href="delete"+location.search;
    }
    upDataDelete();
    getUserInfo();
    getContent();
    getLogin();

</script>
</body>
</html>